package com.suns.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.Random;

@Controller
public class FirstController {
    @GetMapping("/random")
    public String Random(Model model){
        Random rd=new Random();
        model.addAttribute("Result",new Result(0,rd.nextInt(1000),"生成随机数成功"));
        return "Randoms";
    }

    @RequestMapping("/square/{Number}")
    public String Square(Model model ,@PathVariable("Number") Integer Number){
        model.addAttribute("Result",new Result(0,Number*Number,"平方计算成功"));
        return "Squares";
    }
}
